package com.mvprxjavartrofit.ui.home;

import android.content.ContentResolver;

import com.mvprxjavartrofit.entity.User;

import java.util.List;

/**
 * Created by Administrator
 * At 2016/10/20/17:21/2016
 * Project test
 */
public class HomePresenter extends HomeContract.Presenter {

    private HomeContract.Model.ShowListener listener = new HomeContract.Model.ShowListener() {
        @Override
        public void show(List<User> users) {
            view.showQuery(users);
        }
    };

    @Override
    public boolean insert(ContentResolver resolver) {
        model.insert(resolver);
        model.query(resolver, null, null, listener);
        return true;
    }

    @Override
    public boolean delete(ContentResolver resolver
            , String selection, String[] selectionArgs) {
        model.delete(resolver, selection, selectionArgs);
        model.query(resolver, null, null, listener);
        return true;
    }

    @Override
    public boolean update(ContentResolver resolver, String selection, String[] selectionArgs) {
        model.update(resolver, selection, selectionArgs);
        model.query(resolver, null, null, listener);
        return true;
    }


    @Override
    public boolean query(ContentResolver resolver, String selection, String[] selectionArgs) {
        model.query(resolver, selection, selectionArgs, listener);
        return true;
    }
}
